﻿using System;
using System.ComponentModel.DataAnnotations;

namespace AutoClub.Core.Domain
{
    public class RaceMechanic : BaseEntity<Guid>
    {
        private const int maxNumberDigits = 7;

        #region Properties

        [Required]
        private Guid Number { get; set; }

        [Required]
        public Race Race { get; set; }

        [Required]
        public Mechanic Mechanic { get; set; }

        #endregion

        #region Constructors

        public RaceMechanic()
        {

        }

        public RaceMechanic(Race race, Mechanic mechanic)
        {
            this.Number = Guid.NewGuid();
            this.Race = race;
            this.Mechanic = mechanic;
        }

        #endregion

        #region Methods

        public string GetNumber()
        {
            return this.Number.ToString().Substring(0, maxNumberDigits);
        }

        #endregion
    }
}
